using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace SPUpgradeAnalyzer
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void ProcessWeb(TreeNode parentNode, SPWeb web)
        {
            TreeNode node = null;
            if (parentNode == null)
            {
                
                node=treeDesign.Nodes.Add(web.Title + "-" + web.WebTemplate);
            }
            else
                node=parentNode.Nodes.Add(web.Title + "-" + web.WebTemplate);
                foreach (SPList list in web.Lists)
                {
                    TreeNode listNode=new TreeNode("List "+list.Title+"-"+list.BaseTemplate.ToString());
                    TreeNodeCollection nds=treeDesign.Nodes;
                    node.Nodes.Add(listNode);
                    foreach (SPWeb subWeb in web.Webs)
                    {
                        ProcessWeb(node, subWeb);
                    }

                }
            
        }

        private void btnAnalyze_Click(object sender, EventArgs e)
        {
            try
            {
                using (SPSite site = new SPSite(txtUrl.Text))
                {
                    SPWeb web = site.RootWeb;
                    ProcessWeb(null, web);
                }
            }
            catch (Exception Ex)
            {
            }

        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}